use strict;
use warnings;

use Dogtanian;

command svnup => sub {
	say "updating..";
	my $command = "svn up --accept 'mine-full'";
	my @lines = `$command`;

	my $last_line = pop @lines;
	
	my @updated = ();
	my @deleted = ();
	my @added = ();

	for (@lines) {
		if (/^U\s+$Dogtanian::plugin_dir\/([^.]+)\.pl\b/) {
			push @updated, $1;
		} elsif (/^A\s+$Dogtanian::plugin_dir\/([^.]+)\.pl\b/) {
			push @added, $1;
		} elsif (/^D\s+$Dogtanian::plugin_dir\/([^.]+)\.pl\b/) {
			push @deleted, $1;
		}
	}

	say "svnup complete";
	if (@added) {
		say ("new plugins: " . join ',', @added);
	}
	if (@updated) {
		say ("updated plugins: " . join ',', @updated);
	}
	if (@deleted) {
		say ("deleted plugins: " . join ',', @deleted);
	}
}
